package com.biboheart.adapter.support.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class NumberUtils {
    /**
     * 数值转字符串
     * @param number 数值
     * @param fractional 小数后位数
     * @return 转换后的字符串
     */
    public static String numberToString(Number number, int fractional) {
        if (null == number) {
            number = 0;
        }
        return new BigDecimal(String.valueOf(number)).setScale(fractional, RoundingMode.HALF_UP).toString();
    }
}
